\(\int \cot ^2(e+f x) (a+b \sec ^2(e+f x))^p \, dx\) [450]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (warning: unable to verify)
   Maple [F]
   Fricas [F]
   Sympy [F(-1)]
   Maxima [F]
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 23, antiderivative size = 84 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^p \, dx=-\frac {\operatorname {AppellF1}\left (-\frac {1}{2},1,-p,\frac {1}{2},-\tan ^2(e+f x),-\frac {b \tan ^2(e+f x)}{a+b}\right ) \cot (e+f x) \left (a+b+b \tan ^2(e+f x)\right )^p \left (1+\frac {b \tan ^2(e+f x)}{a+b}\right )^{-p}}{f} \]

[Out]

-AppellF1(-1/2,1,-p,1/2,-tan(f*x+e)^2,-b*tan(f*x+e)^2/(a+b))*cot(f*x+e)*(a+b+b*tan(f*x+e)^2)^p/f/((1+b*tan(f*x
+e)^2/(a+b))^p)

Rubi [A] (verified)

Time = 0.15 (sec) , antiderivative size = 84, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.174, Rules used = {4226, 2000, 525, 524} \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^p \, dx=-\frac {\cot (e+f x) \left (a+b \tan ^2(e+f x)+b\right )^p \left (\frac {b \tan ^2(e+f x)}{a+b}+1\right )^{-p} \operatorname {AppellF1}\left (-\frac {1}{2},1,-p,\frac {1}{2},-\tan ^2(e+f x),-\frac {b \tan ^2(e+f x)}{a+b}\right )}{f} \]

[In]

Int[Cot[e + f*x]^2*(a + b*Sec[e + f*x]^2)^p,x]

[Out]

-((AppellF1[-1/2, 1, -p, 1/2, -Tan[e + f*x]^2, -((b*Tan[e + f*x]^2)/(a + b))]*Cot[e + f*x]*(a + b + b*Tan[e +
f*x]^2)^p)/(f*(1 + (b*Tan[e + f*x]^2)/(a + b))^p))

Rule 524

Int[((e_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Simp[a^p*c^q*
((e*x)^(m + 1)/(e*(m + 1)))*AppellF1[(m + 1)/n, -p, -q, 1 + (m + 1)/n, (-b)*(x^n/a), (-d)*(x^n/c)], x] /; Free
Q[{a, b, c, d, e, m, n, p, q}, x] && NeQ[b*c - a*d, 0] && NeQ[m, -1] && NeQ[m, n - 1] && (IntegerQ[p] || GtQ[a
, 0]) && (IntegerQ[q] || GtQ[c, 0])

Rule 525

Int[((e_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Dist[a^IntPar
t[p]*((a + b*x^n)^FracPart[p]/(1 + b*(x^n/a))^FracPart[p]), Int[(e*x)^m*(1 + b*(x^n/a))^p*(c + d*x^n)^q, x], x
] /; FreeQ[{a, b, c, d, e, m, n, p, q}, x] && NeQ[b*c - a*d, 0] && NeQ[m, -1] && NeQ[m, n - 1] &&  !(IntegerQ[
p] || GtQ[a, 0])

Rule 2000

Int[(u_)^(p_.)*(v_)^(q_.)*((e_.)*(x_))^(m_.), x_Symbol] :> Int[(e*x)^m*ExpandToSum[u, x]^p*ExpandToSum[v, x]^q
, x] /; FreeQ[{e, m, p, q}, x] && BinomialQ[{u, v}, x] && EqQ[BinomialDegree[u, x] - BinomialDegree[v, x], 0]
&&  !BinomialMatchQ[{u, v}, x]

Rule 4226

Int[((a_) + (b_.)*sec[(e_.) + (f_.)*(x_)]^(n_))^(p_.)*((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> With[
{ff = FreeFactors[Tan[e + f*x], x]}, Dist[ff/f, Subst[Int[(d*ff*x)^m*((a + b*(1 + ff^2*x^2)^(n/2))^p/(1 + ff^2
*x^2)), x], x, Tan[e + f*x]/ff], x]] /; FreeQ[{a, b, d, e, f, m, p}, x] && IntegerQ[n/2] && (IntegerQ[m/2] ||
EqQ[n, 2])

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {\left (a+b \left (1+x^2\right )\right )^p}{x^2 \left (1+x^2\right )} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {\text {Subst}\left (\int \frac {\left (a+b+b x^2\right )^p}{x^2 \left (1+x^2\right )} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {\left (\left (a+b+b \tan ^2(e+f x)\right )^p \left (1+\frac {b \tan ^2(e+f x)}{a+b}\right )^{-p}\right ) \text {Subst}\left (\int \frac {\left (1+\frac {b x^2}{a+b}\right )^p}{x^2 \left (1+x^2\right )} \, dx,x,\tan (e+f x)\right )}{f} \\ & = -\frac {\operatorname {AppellF1}\left (-\frac {1}{2},1,-p,\frac {1}{2},-\tan ^2(e+f x),-\frac {b \tan ^2(e+f x)}{a+b}\right ) \cot (e+f x) \left (a+b+b \tan ^2(e+f x)\right )^p \left (1+\frac {b \tan ^2(e+f x)}{a+b}\right )^{-p}}{f} \\ \end{align*}

Mathematica [B] (warning: unable to verify)

Leaf count is larger than twice the leaf count of optimal. \(2469\) vs. \(2(84)=168\).

Time = 17.48 (sec) , antiderivative size = 2469, normalized size of antiderivative = 29.39 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^p \, dx=\text {Result too large to show} \]

[In]

Integrate[Cot[e + f*x]^2*(a + b*Sec[e + f*x]^2)^p,x]

[Out]

((a + 2*b + a*Cos[2*(e + f*x)])^p*Cot[e + f*x]^3*(Sec[e + f*x]^2)^p*(a + b*Sec[e + f*x]^2)^p*(-(Hypergeometric
2F1[-1/2, -p, 1/2, -((b*Tan[e + f*x]^2)/(a + b))]/(1 + (b*Tan[e + f*x]^2)/(a + b))^p) - (3*(a + b)*AppellF1[1/
2, -p, 1, 3/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sin[e + f*x]^2)/(3*(a + b)*AppellF1[1/2, -p, 1,
 3/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2] + 2*(b*p*AppellF1[3/2, 1 - p, 1, 5/2, -((b*Tan[e + f*x]^
2)/(a + b)), -Tan[e + f*x]^2] - (a + b)*AppellF1[3/2, -p, 2, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]
^2])*Tan[e + f*x]^2)))/(f*(2*p*(a + 2*b + a*Cos[2*(e + f*x)])^p*(Sec[e + f*x]^2)^p*(-(Hypergeometric2F1[-1/2,
-p, 1/2, -((b*Tan[e + f*x]^2)/(a + b))]/(1 + (b*Tan[e + f*x]^2)/(a + b))^p) - (3*(a + b)*AppellF1[1/2, -p, 1,
3/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sin[e + f*x]^2)/(3*(a + b)*AppellF1[1/2, -p, 1, 3/2, -((b
*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2] + 2*(b*p*AppellF1[3/2, 1 - p, 1, 5/2, -((b*Tan[e + f*x]^2)/(a + b)
), -Tan[e + f*x]^2] - (a + b)*AppellF1[3/2, -p, 2, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2])*Tan[e
 + f*x]^2)) - (a + 2*b + a*Cos[2*(e + f*x)])^p*Csc[e + f*x]^2*(Sec[e + f*x]^2)^p*(-(Hypergeometric2F1[-1/2, -p
, 1/2, -((b*Tan[e + f*x]^2)/(a + b))]/(1 + (b*Tan[e + f*x]^2)/(a + b))^p) - (3*(a + b)*AppellF1[1/2, -p, 1, 3/
2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sin[e + f*x]^2)/(3*(a + b)*AppellF1[1/2, -p, 1, 3/2, -((b*T
an[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2] + 2*(b*p*AppellF1[3/2, 1 - p, 1, 5/2, -((b*Tan[e + f*x]^2)/(a + b)),
 -Tan[e + f*x]^2] - (a + b)*AppellF1[3/2, -p, 2, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2])*Tan[e +
 f*x]^2)) - 2*a*p*(a + 2*b + a*Cos[2*(e + f*x)])^(-1 + p)*Cot[e + f*x]*(Sec[e + f*x]^2)^p*Sin[2*(e + f*x)]*(-(
Hypergeometric2F1[-1/2, -p, 1/2, -((b*Tan[e + f*x]^2)/(a + b))]/(1 + (b*Tan[e + f*x]^2)/(a + b))^p) - (3*(a +
b)*AppellF1[1/2, -p, 1, 3/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sin[e + f*x]^2)/(3*(a + b)*Appell
F1[1/2, -p, 1, 3/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2] + 2*(b*p*AppellF1[3/2, 1 - p, 1, 5/2, -((b
*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2] - (a + b)*AppellF1[3/2, -p, 2, 5/2, -((b*Tan[e + f*x]^2)/(a + b)),
 -Tan[e + f*x]^2])*Tan[e + f*x]^2)) + (a + 2*b + a*Cos[2*(e + f*x)])^p*Cot[e + f*x]*(Sec[e + f*x]^2)^p*((2*b*p
*Hypergeometric2F1[-1/2, -p, 1/2, -((b*Tan[e + f*x]^2)/(a + b))]*Sec[e + f*x]^2*Tan[e + f*x]*(1 + (b*Tan[e + f
*x]^2)/(a + b))^(-1 - p))/(a + b) - (6*(a + b)*AppellF1[1/2, -p, 1, 3/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e
 + f*x]^2]*Cos[e + f*x]*Sin[e + f*x])/(3*(a + b)*AppellF1[1/2, -p, 1, 3/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan
[e + f*x]^2] + 2*(b*p*AppellF1[3/2, 1 - p, 1, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2] - (a + b)*A
ppellF1[3/2, -p, 2, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2])*Tan[e + f*x]^2) - (3*(a + b)*Sin[e +
 f*x]^2*((2*b*p*AppellF1[3/2, 1 - p, 1, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sec[e + f*x]^2*Ta
n[e + f*x])/(3*(a + b)) - (2*AppellF1[3/2, -p, 2, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sec[e +
 f*x]^2*Tan[e + f*x])/3))/(3*(a + b)*AppellF1[1/2, -p, 1, 3/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]
 + 2*(b*p*AppellF1[3/2, 1 - p, 1, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2] - (a + b)*AppellF1[3/2,
 -p, 2, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2])*Tan[e + f*x]^2) - (Csc[e + f*x]*Sec[e + f*x]*(Hy
pergeometric2F1[-1/2, -p, 1/2, -((b*Tan[e + f*x]^2)/(a + b))] - (1 + (b*Tan[e + f*x]^2)/(a + b))^p))/(1 + (b*T
an[e + f*x]^2)/(a + b))^p + (3*(a + b)*AppellF1[1/2, -p, 1, 3/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^
2]*Sin[e + f*x]^2*(4*(b*p*AppellF1[3/2, 1 - p, 1, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2] - (a +
b)*AppellF1[3/2, -p, 2, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2])*Sec[e + f*x]^2*Tan[e + f*x] + 3*
(a + b)*((2*b*p*AppellF1[3/2, 1 - p, 1, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sec[e + f*x]^2*Ta
n[e + f*x])/(3*(a + b)) - (2*AppellF1[3/2, -p, 2, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sec[e +
 f*x]^2*Tan[e + f*x])/3) + 2*Tan[e + f*x]^2*(b*p*((-6*AppellF1[5/2, 1 - p, 2, 7/2, -((b*Tan[e + f*x]^2)/(a + b
)), -Tan[e + f*x]^2]*Sec[e + f*x]^2*Tan[e + f*x])/5 - (6*b*(1 - p)*AppellF1[5/2, 2 - p, 1, 7/2, -((b*Tan[e + f
*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sec[e + f*x]^2*Tan[e + f*x])/(5*(a + b))) - (a + b)*((6*b*p*AppellF1[5/2, 1
- p, 2, 7/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sec[e + f*x]^2*Tan[e + f*x])/(5*(a + b)) - (12*Ap
pellF1[5/2, -p, 3, 7/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2]*Sec[e + f*x]^2*Tan[e + f*x])/5))))/(3*
(a + b)*AppellF1[1/2, -p, 1, 3/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2] + 2*(b*p*AppellF1[3/2, 1 - p
, 1, 5/2, -((b*Tan[e + f*x]^2)/(a + b)), -Tan[e + f*x]^2] - (a + b)*AppellF1[3/2, -p, 2, 5/2, -((b*Tan[e + f*x
]^2)/(a + b)), -Tan[e + f*x]^2])*Tan[e + f*x]^2)^2)))

Maple [F]

\[\int \cot \left (f x +e \right )^{2} \left (a +b \sec \left (f x +e \right )^{2}\right )^{p}d x\]

[In]

int(cot(f*x+e)^2*(a+b*sec(f*x+e)^2)^p,x)

[Out]

int(cot(f*x+e)^2*(a+b*sec(f*x+e)^2)^p,x)

Fricas [F]

\[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^p \, dx=\int { {\left (b \sec \left (f x + e\right )^{2} + a\right )}^{p} \cot \left (f x + e\right )^{2} \,d x } \]

[In]

integrate(cot(f*x+e)^2*(a+b*sec(f*x+e)^2)^p,x, algorithm="fricas")

[Out]

integral((b*sec(f*x + e)^2 + a)^p*cot(f*x + e)^2, x)

Sympy [F(-1)]

Timed out. \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^p \, dx=\text {Timed out} \]

[In]

integrate(cot(f*x+e)**2*(a+b*sec(f*x+e)**2)**p,x)

[Out]

Timed out

Maxima [F]

\[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^p \, dx=\int { {\left (b \sec \left (f x + e\right )^{2} + a\right )}^{p} \cot \left (f x + e\right )^{2} \,d x } \]

[In]

integrate(cot(f*x+e)^2*(a+b*sec(f*x+e)^2)^p,x, algorithm="maxima")

[Out]

integrate((b*sec(f*x + e)^2 + a)^p*cot(f*x + e)^2, x)

Giac [F]

\[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^p \, dx=\int { {\left (b \sec \left (f x + e\right )^{2} + a\right )}^{p} \cot \left (f x + e\right )^{2} \,d x } \]

[In]

integrate(cot(f*x+e)^2*(a+b*sec(f*x+e)^2)^p,x, algorithm="giac")

[Out]

integrate((b*sec(f*x + e)^2 + a)^p*cot(f*x + e)^2, x)

Mupad [F(-1)]

Timed out. \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^p \, dx=\int {\mathrm {cot}\left (e+f\,x\right )}^2\,{\left (a+\frac {b}{{\cos \left (e+f\,x\right )}^2}\right )}^p \,d x \]

[In]

int(cot(e + f*x)^2*(a + b/cos(e + f*x)^2)^p,x)

[Out]

int(cot(e + f*x)^2*(a + b/cos(e + f*x)^2)^p, x)